<template>
  <div class="recommend-list">
    <div class="recommend-item" v-for="item in recommendList" :key="item.id" @click="$router.push(`/productDetail/${item.id}`)">
      <img :src="item.imageHost + item.mainImage" alt="图片未加载成功" />
      <p>{{ item.name }}</p>
      <span>￥&nbsp;{{ item.price }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    recommendList: {
      type: Array,
      require: true,
      default() {
        return []
      },
    },
  },
}
</script>

<style lang="scss" scoped>
.recommend-list {
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 100px;
  background-color: white;
  .recommend-item {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #dcdcdc;
    box-sizing: border-box;
    img {
      width: 100%;
      height: 300px;
    }
    &:nth-child(2n-1) {
      border-right: 1px solid #dcdcdc;
    }
    p {
      font-size: 20px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}
</style>
